package com.company.demo.handlers;

//定义处理器

import com.company.demo.bean.Country;
import com.company.demo.bean.Group;
import com.company.demo.bean.Student;
import com.company.demo.service.ISomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.concurrent.CountDownLatch;

@RequestMapping("/test")
//@PropertySource(value="classpath:myapp.properties",encoding="utf-8")
@Controller
public class SomeHandler {

//    @Value("${student.name}")//学生属性值注入
//    private String name;

//    @Autowired//方法注入
//    private ISomeService service;

//    @Autowired//学生类注入
//    private Student student;

//    @Autowired//城市类注入
//    private Country country;

    @Autowired//读取list<object>
    private Group group;

    @RequestMapping("/some")
    public @ResponseBody String someHandler(){
        //返回方法
//        return service.send();

        //返回学生属性值
//        return "hello :"+this.name;

        //返回学生类
//        System.out.println("student="+student);
//        return student.getName();

        //读取List<Student>
//        for (String city:country.getCities() ) {
//            System.out.println(city);
//        }
//        return country.toString();


        //读取List<Object>
        for (Student student:group.getStudents() ) {
            System.out.println(student);
        }
        return group.toString();


    }
}
